/*
Copyright 2005-2014 CP Fricano - All Rights Reserved

This software and source code is licensed under the Apache
License, Version 2.0. You may not use this software or source
code except in compliance with the License.  You may obtain a
copy of the License at: http://www.apache.org/licenses/LICENSE-2.0.
Use and distributed under this License is on an "as is" basis,
without expressed or implied warranties or conditions of any kind.
See the License for the specific language governing permissions and
limitations.
 */

package com.fricano.java42.swing.dings.tester;

import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;

import com.fricano.java42.swing.dings.J42SwingDingController_SlideWindow.Alignment;
import com.fricano.java42.swing.dings.J42SwingDingManager_SlideWindow;
import com.fricano.java42.swing.dings.J42SwingDing_Factory;

final public class J42SwingDing_SlidableTest_00 {

    final static JButton                    jButton    = new JButton("Slide");
    final static JFrame                     jFrame     = new JFrame();
    final static J42SwingDing_Factory       controller = new J42SwingDing_Factory(jFrame);
    final static J42SwingDingManager_SlideWindow manager    = controller.create_SlideManager();
    final static JButton                    slider     = new JButton("SimpleSlideTest");

    static public void main(final String[] args) throws Exception {

        slider.setSize(150, 80);

        jFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        jFrame.setLocationRelativeTo(null);
        jFrame.setLayout(new FlowLayout());

        jButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(final ActionEvent actionEvent) {
                if (manager.isClosed()) {
                    manager.slideOpen(true);
                }
                else {
                    manager.slideClosed(true);
                }
            }
        });

        SwingUtilities.invokeAndWait(new Runnable() {
            @Override
            public void run() {
                jFrame.add(jButton);
                jFrame.pack();
                jFrame.setVisible(true);
            }
        });

        manager.attachSlider(Alignment.EXTERIOR_RIGHT, slider, 42, 500, 0, 0);
    }
}
